package com.ohy.tencent.config;

import cn.hutool.core.io.FileUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class VideoConfig implements WebMvcConfigurer {
    @Value("${video.visit.path}")
    private String visitPath;

    @Value("${windows.video.upload.path}")
    private String windowsUploadPath;

    @Value("${centos.video.upload.path}")
    private String centosUploadPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String uploadPath = FileUtil.isWindows() ? windowsUploadPath : centosUploadPath;

        registry.addResourceHandler(visitPath + "**").addResourceLocations("file:" + uploadPath);
    }
}